<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>提交质检单</title>
	    <link rel="stylesheet" href="css/AllStyle.css" />
	    <link rel="stylesheet" href="css/iconfont.css" />
	    <script type="text/javascript" src="js/common.js" ></script>
	    <script type="text/javascript" src="js/companydata.js" ></script>
	    <script type="text/javascript" src="js/data.js" ></script>
	    <script type="text/javascript" src="js/tmpl.js" ></script>
	</head>
	<body>
		<!-- 页头 -->
	    <section>
		    <script type="text/javascript">
		        AllPageHeader()
		    </script>
	    </section>

	    <!-- 页面  -->
	    <section class="AllContent">
	    	<form>
	    		<div class="FormStyle">
					<ul>
						<li>工程名称</li>
						<li>
							<input id="engineName" disabled/>
						</li>
						<li>工序名称</li>
						<li>
							<input id="procName" disabled/>
						</li>
						<li>报工单号</li>
						<li>
							<input id="reportNo" disabled/>
						</li>
						<li>报  工  人</li>
						<li>
							<input id="realName" disabled/>
						</li>
						<li>报工时间</li>
						<li>
							<input id="reportTime" disabled/>
						</li>
						<li>报工数量</li>
						<li>
							<input id="reportCount" disabled/>
						</li>
						<li>在制数量</li>
						<li>
							<input id="inProcCount" disabled/>
						</li>
						<li>合格数量</li>
						<li>
							<input id="qualifiedCount" disabled/>
						</li>
						<li>未检数量</li>
						<li>
							<input id="noQualifiedCount" disabled/>
						</li>
						<li>质检数量</li>
						<li>
							<input type="number" id="count" style="width: 220px;" placeholder="请输入质检数量" autofocus="autofocus"/>
						</li>

					</ul>
					<div style="text-align: center;">
						<button class="Quality NextButton" type="button" style="width: 70%; font-size: 20px; margin: 10px;">提交质检单</button>
					</div>
				</div>
			</form>
		</section>
	</body>

	<script src="js/mui.min.js"></script>
	<script src="js/jquery.min.js"></script>
	<script src="js/common.js"></script>
	<script src="js/data.js"></script>
	<script type="text/javascript">
		var sData;
		mui.init();
		$('.AllHeader li:eq(1)').text('提交质检单')
		$(function(){
			if(getCookie("token") === null || getCookie("token") === ''){
				window.location.href='login.html';
				return;
			}

			mui.ajax(getServerUrl()+"/quality/qualityTesting/selectQualityTestingByReportId",{
				headers:{
					"X-Access-Token":getCookie("token")
				},
				data:{'reportId':$_GET['reportId']},
				type:'get',
				timeout:100000,
				success:function(data){
					$('#engineName').val(data.engineName);
					$('#procName').val(data.procName);
					$('#reportNo').val(data.reportNo);
					$('#reportCount').val(data.reportCount);
					$('#realName').val(data.realName);
					$('#reportTime').val(data.reportTime);
					$('#inProcCount').val(data.inProcCount);
					$('#qualifiedCount').val(data.qualifiedCount);
					$('#noQualifiedCount').val(data.reportCount - data.qualifiedCount);
				},
				error:function(xhr,type,errorThrown){
				}
			});
		});
		mui('body').on('tap', '.Quality', function() {
			var count = $('#count').val();
			if(count === undefined || count === ''){
				alert("请输入质检数量！");
				return;
			}
			if(parseInt(count) <= 0){
				alert("您输入正确的质检数量！");
				return;
			}
			if(parseInt($('#noQualifiedCount').val()) < parseInt(count)){
				alert("您输入的质检数量大于报工数量了！");
				return;
			}
			$.ajax(getServerUrl()+'/quality/qualityTesting/submitQuality',{
				headers:{
					"X-Access-Token":getCookie("token")
				},
				data:{'reportId':$_GET['reportId'],'qualityCount':parseInt(count)},
				type:'post',
				timeout:100000,
				success:function(data){
					mui.toast("质检成功")
					window.location.href='qualityList.html'
				},
				error:function(xhr,type,errorThrown){
					window.location.href='login.html';
				}
			});
			mui('body').on('tap', '.myFirstPage', function() {
				mui.openWindow({
					url:'supper.html',
					id:'supper.html',
				})
			});
		})
	</script>
	<style>
		input{
			background:transparent;
			color:#aaa;
			border:1px solid #aaa;

		}
	</style>
</html>
